import request from '@/utils/request'

// 获取spu列表数据的接口
// GET /admin/product/{page}/{limit}  params参数,kv一致省略v
export const reqSpuList = (page, limit, category3Id) => request({ url: `/dev1-api/admin/product/${page}/${limit}`, method: 'get', params: { category3Id } })

// 获取spu信息
// /admin/product/getSpuById/{spuId}  get
export const reqSpu = (spuId) => request({ url: `/dev1-api/admin/product/getSpuById/${spuId}`, method: 'get' })

// 获取品牌的信息  GET /admin/product/baseTrademark/getTrademarkList  
export const reqTradeMarkList = () => request({ url: `/dev1-api/admin/product/baseTrademark/getTrademarkList`, method: 'get' })

// 获取SPU图片的接口 /admin/product/spuImageList/{spuId}  get
export const reqSpuImageList = (spuId) => request({ url: `/dev1-api/admin/product/spuImageList/${spuId}`, method: 'get' })

// 获取销售属性（3个）/admin/product/baseSaleAttrList  get
export const reqBaseSaleAttrList = () => request({ url: `/dev1-api/admin/product/baseSaleAttrList`, method: 'get' })

// 修改SPU 或者 添加新的SPU：对于修改、添加，携带给服务器参数大致是一样的，唯一区别就是携带的参数是否带id
export const reqAddOrUpdateSpu = (spuInfo) => {
    if (spuInfo.id) {
        // 携带的参数有id----则是修改SPU
        return request({ url: `/dev1-api/admin/product/updateSpuInfo`, method: 'post', data: spuInfo })
    } else {
        // 携带的参数无id则是---新增SPU
        return request({ url: `/dev1-api/admin/product/saveSpuInfo`, method: 'post', data: spuInfo })
    }
}

// 删除SPU  /admin/product/deleteSpu/{spuId}
export const reqDeleteSpu = (spuId) => request({ url: `/dev1-api/admin/product/deleteSpu/${spuId}`, method: 'delete' })

// 获取图片接口  /admin/product/spuImageList/{spuId}  get
export const reqSpuImageLists = (spuId) => request({ url: `/dev1-api/admin/product/spuImageList/${spuId}`, method: 'get' })

// 获取销售属性  /admin/product/spuSaleAttrList/{spuId}  get
export const reqSpuSaleAttrList = (spuId) => request({ url: `/dev1-api/admin/product/spuSaleAttrList/${spuId}`, method: 'get' })

// 获取平台属性的数据
// GET  /admin/product/attrInfoList/{category1Id}/{category2Id}/{category3Id}
export const reqAttrInfoList = (category1Id, category2Id, category3Id) => request({ url: `/dev1-api/admin/product/attrInfoList/${category1Id}/${category2Id}/${category3Id}`, method: 'get' })

// 添加SKU /admin/product/saveSkuInfo  POST
export const reqAddSku = (skuInfo) => request({ url: `/dev1-api/admin/product/saveSkuInfo`, method: 'post', data: skuInfo })

//获取SKU列表数据的接口 /admin/product/findBySpuId/{spuId}  GET
export const reqSkuList = (spuId) => request({ url: `/dev1-api/admin/product/findBySpuId/${spuId}`, method: 'get' })